package com.chench.ai.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChatController {

    private final ChatClient chatClient;

    public ChatController(ChatClient.Builder clientBuilder) {
        this.chatClient = clientBuilder.build();
    }

    @GetMapping("/prompt")
    public String prompt(@RequestParam(value = "msg", defaultValue = "请问，你是谁？") String message) {
        return chatClient.prompt()//提示词
                .user(message)//用户输入内容
                .call()//请求大模型
                .content();// 返回结果文本

    }
}
